// components/bookcard/bookcard.js
const ui = require('../../utils/ui')
const util = require('../../utils/util')

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    id: {type: Number},
    status: {type: Number},
    cover: {type: String},
    title: {type: String},
    desc: {type: String},
    price: {type: Number},
    memberPrice: {type: Number},
    timeList: {type: Array},
    endTime:{type:String},
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {

    _preview(event) {
      let currentUrl = event.currentTarget.dataset.src
      wx.previewImage({
        current: currentUrl,
        urls: [currentUrl]
      })
    },

    preOrder(){
      let tel = getApp().globalData.tel
      if (tel == "" || tel == null) {
        wx.navigateTo({
          url: '/pages/login/login',
        })
      }
      else {
        if (this.data.status == 3) {
          //待清洁
          this.triggerEvent("triggerStoreDialog", this.id)
        }
        else if (this.data.status == 0) {
          ui.showToast({
            title: '房间在维护，请预定其他房间',
          })
        }
        else {
          wx.navigateTo({
            // url: '/pages/submit_order/submit_order?itemId='+this.id,
            url: '/pages/submit_order/submit_order'+util.paramsWrap({
              itemId: this.id,
              status: this.data.status
            })
          })
        }
      }
    },

  }
})
